package com.origin.uilibrary.dailog.bese;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatDialog;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.origin.uilibrary.R;


public abstract class CustomDialog<VB extends ViewDataBinding> extends AppCompatDialog {
    private VB dialogViewBinding;

    public VB getDialogViewBinding() {
        return dialogViewBinding;
    }

    public Context mContext;
    public CustomDialog(Context context) {
        super(context, R.style.BaseDialogStyle);
        mContext=context;
    }

    public CustomDialog(Context context, int theme) {
        super(context, theme);
        mContext=context;
    }

    protected CustomDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        mContext=context;
    }

    public void doAction() {

    }

    /**
     * 设置dialog布局
     *
     * @return
     */
    public abstract int setUpLayoutId();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        dialogViewBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), setUpLayoutId(), null, false);
        setContentView(dialogViewBinding.getRoot());
        doAction();
    }

    public void dismissDialog() {
        super.dismiss();
    }

    public CustomDialog showDialog() {

        super.show();

        return this;
    }

}
